<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function(){
	        	var result = "";
				$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
					if(validateEmpty()){
						result = dateDiff($("#startDate").val(), $("#endDate").val(),"/");
			        	if (!result && $("#startDate").val() != "" && $("#endDate").val() != "") {
			        		alert("วันเริ่มต้นต้องน้อยกว่าวันสิ้นสุดกรุณาระบุใหม่");
			        		$("#endDate").val("");
							return false;
			        	} else {
							$("#searchForm").submit();
						}
					} else {
						return false;
					}
		        });
				$("#budgetYear").change(function(){
					if ($("#budgetYear").val() != "") {
						$("#startDate").val("01/10/"+($("#budgetYear").val()-1));
					}else {
						$("#startDate").val("");
					}
				});
		        thaiDatepicker("startDate","#","1");
		        thaiDatepicker("endDate","#","1");
			});
		function listTransactionType(value){
			var dhtml = new DHTML();
			dhtml.removeElement(document.getElementById("transactionType"));
			var select = dhtml.createElement(document.getElementById("transactionTypeSpan"), ["select","name=transactionType","id=transactionType"], "");
			var option = dhtml.createElement(select,["option","value="],"----- เลือก -----");
			if (value == "I") {
				var option1 = dhtml.createElement(select,["option","value=B"],"ยอดยกมา");
				var option2 = dhtml.createElement(select,["option","value=S"],"รับโอนจาก สปสช.");
				var option3 = dhtml.createElement(select,["option","value=O"],"รายรับอื่น");
			} else {
				var option1 = dhtml.createElement(select,["option","value=T"],"จ่ายโอน");
				var option2 = dhtml.createElement(select,["option","value=C"],"จ่าย cheque");
				var option3 = dhtml.createElement(select,["option","value=P"],"จ่ายอื่นๆ");
			}
		}
		</script>
	</head>
	<body>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post" target = "_blank">
		<input type="hidden" name="app" id="app" value="ACC6REPORT"/>
		<input type="hidden" name="job" id="job" value="ACC6REPORT008"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC6REPORT008}</b></th>
			</tr>
			<tr>
				<td class="bold">จังหวัด : </td>
				<td>
					<c:if test="${userInfo.areaLevel =='3'}">
						<c:forEach var="data" items="${userInfo.listUserProvice}">
							${data.provinceName}
							<input type="hidden" name="provinceId" id="provinceId" value="${data.provinceId}">
						</c:forEach>
					</c:if>
					<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
						<select name="provinceId" id="provinceId">
							<option value="">----- เลือก -----</option>
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								<c:if test="${data.provinceId == provinceId}" var="provinceSeleted"/>
								<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
							</c:forEach>
						</select>
					</c:if>
				</td>
			</tr>
			<tr>
				<td class="bold">ปีที่ออกรายงาน : </td>
				<td>
					<select name="budgetYear" id="budgetYear">
						<option value="">----- เลือก -----</option>
						<c:forEach items="${lsBudgetYear}" var="data">
							<c:if test="${budgetYear == data.BUDGET_YEAR}" var="selected"/>
							<option value="${data.BUDGET_YEAR}" ${selected?'selected':''}>${data.BUDGET_YEAR}</option>
						</c:forEach>
					</select>
					<span id="$budgetYear" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">วันที่ออกรายงาน : </td>
				<td>
					<input type="text" name="startDate" id="startDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${startDate}"/>
					<span id="#startDate" class="red">*</span>
					ถึงวันที่
					<input type="text" name="endDate" id="endDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${endDate}"/>
					<span id="#endDate" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">ประเภทข้อมูล  : </td>
				<td>
					<input type="radio" name="type" id="typeI" value="I" onclick="listTransactionType('I');"/> รายรับ 
					&nbsp;&nbsp;&nbsp;
					<input type="radio" name="type" id="typeE" value="E" onclick="listTransactionType('E');"/> รายจ่าย
					<span id="@type" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">ลักษณะข้อมูล  : </td>
				<td>
					<span id="transactionTypeSpan">
						<select name="transactionType" id="transactionType">
							<option>----- เลือก -----</option>
							<!-- <option value="B">ยอดยกมา</option>
							<option value="S">รับโอนจาก สปสช.</option>
							<option value="O">รายรับอื่น</option>
							<option value="T">จ่ายโอน</option>
							<option value="C">จ่าย cheque</option>
							<option value="P">จ่ายอื่นๆ</option> -->
						</select>
					</span>
					<span id="$type" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">สถานะการจ่าย : </td>
				<td>
					<select name="expenseStatus" id="expenseStatus">
						<option value="">----- เลือก -----</option>
						<c:forEach var="es" items="${expenseStatus}">
							<c:if var="statusSelected" test="${expenseStatusSel == es.key}"/>
							<c:if test="${es.key != 'S'}">
								<option value="${es.key}"} ${statusSelected?'selected':''}>${es.value}</option>
							</c:if>
					    </c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<button type="button" name="btnSearch" id="btnSearch" class="acc67-button"> ค้นหาข้อมูล </button>
					<!-- <button type="button" name="btnExport" id="btnExport" class="acc67-button"> Download </button> -->
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>